import 'package:alice_screen/common/constant.dart';
import 'package:alice_screen/guide/guide_add_device.dart';
import 'package:alice_screen/guide/guide_bind_device.dart';
import 'package:alice_screen/guide/guide_config_wifi.dart';
import 'package:alice_screen/guide/guide_install.dart';
import 'package:alice_screen/util/image_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';

import 'guide_download.dart';

class GuidePage extends StatefulWidget {
  GuidePage({Key key}) : super(key: key);

  @override
  _GuidePageState createState() => _GuidePageState();
}

class _GuidePageState extends State<GuidePage> {

  final controller = PageController(viewportFraction: 1);

  var list = List();

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    list.add(GuideDownload());
    list.add(GuideInstall());
    list.add(GuideAddDevice());
    list.add(GuideBindDevice());
    list.add(GuideConfigWifi());
  }

  @override
  Widget build(BuildContext context) {
    
    //初始化UI设计界面的宽和高
    ScreenUtil.init(context, width: Constant.uiDesignWidth,
      height: Constant.uiDesignHeight);
      
    return Scaffold(
      body: Stack(
        alignment: Alignment.center,
        children: <Widget>[
          Image.asset(
            ImageUtils.getImgPath('apps_bg', format: 'jpg'),
            width: double.infinity,
            fit: BoxFit.fill,
            height: double.infinity,
          ),
          PageView(
            controller: controller,
            children: List.generate(
              list.length,
              (index) => list[index]
            ),
          ),
          Positioned(
            bottom: ScreenUtil().setHeight(36.0),
            child: SmoothPageIndicator(
              controller: controller,
              count: list.length,
              effect: SlideEffect(
                spacing: ScreenUtil().setWidth(26.0),
                dotWidth: ScreenUtil().setWidth(18.0),
                dotHeight: ScreenUtil().setHeight(18.0),
                paintStyle: PaintingStyle.fill,
                dotColor: Color(0x33FFFFFF),
                activeDotColor: Color(0xCCFFFFFF)
              ),
            )
          )
        ],
      ),
    );
  }
}